package com.example;

import com.example.entity.ClassTable;
import com.example.service.ClassTableService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.List;

@Controller
public class ClassTableController
{

    private final ClassTableService classTableService;

    @Autowired
    public ClassTableController(ClassTableService classTableService) {
        this.classTableService = classTableService;
    }

    @GetMapping("/ClassTable")
    public String getClassTable(Model model) {
        List<ClassTable> classTables = classTableService.findAllClass();
        model.addAttribute("classTables", classTables);
        return "ClassTable"; // HTML页面的名称应与返回的字符串相匹配
    }
}
